// Include files.
#include "CompoundService.hpp"

using namespace std;

/**
 *  Constructor for CompoundService.
 */
CompoundService::CompoundService()
{
}

/**
 *  Destructor for CompoundService.
 */
CompoundService::~CompoundService()
{
}

/**
 *  Adds a service to the list of services to be started or stopped when the CompoundService gets started or stopped (respectivly).
 *  
 *  @param service A reference to the service to be started or stopped when the CompoundService gets started or stopped (respectivly).
 */
void CompoundService::AddService(Service &service)
{
	// For efficiency, CompoundService uses Service's own m_subservices to store compounded services.
	AddSubservice(service);
}

/**
 *  Handle when the CompoundService is started.
 */
void CompoundService::HandleStart()
{
	set<Service*>::iterator it;
	
	// For efficiency, CompoundService uses Service's own m_subservices to store compounded services.
	for (it = m_subservices.begin(); it != m_subservices.end(); ++it)
		(*it)->Start();
}
